<!DOCTYPE html>
<html>
<head>
    <!-- 页面meta -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>传智健康</title>
    <meta name="description" content="传智健康">
    <meta name="keywords" content="传智健康">
    <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
    <!-- 引入样式 -->
    <link rel="stylesheet" href="../plugins/elementui/index.css">
    <link rel="stylesheet" href="../plugins/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="../css/style.css">
    <!-- 引入组件库 -->
    <script type="text/javascript" src="../js/jquery.min.js"></script>
    <script src="../js/vue.js"></script>
    <script src="../plugins/elementui/index.js"></script>
    <script src="../js/axios-0.18.0.js"></script>
    <style>
        .datatable {
            position: relative;
            box-sizing: border-box;
            -webkit-box-flex: 1;
            width: 100%;
            max-width: 100%;
            font-size: 14px;
            color: rgb(96, 98, 102);
            overflow: hidden;
            flex: 1 1 0%;
        }

        .datatable td, .datatable th {
            padding: 12px 0;
            min-width: 0;
            -webkit-box-sizing: border-box;
            box-sizing: border-box;
            text-overflow: ellipsis;
            vertical-align: middle;
            position: relative;
            text-align: left;
        }
    </style>
</head>
<body class="hold-transition">
<div id="app">
    <div class="content-header">
        <h1>健康干预
            <small>人群管理</small>
        </h1>
        <el-breadcrumb separator-class="el-icon-arrow-right" class="breadcrumb">
            <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>健康干预</el-breadcrumb-item>
            <el-breadcrumb-item>人群管理</el-breadcrumb-item>
        </el-breadcrumb>
    </div>
    <div class="app-container">
        <div class="box">
            <div class="filter-container">
                <el-input placeholder="档案号/姓名" v-model="pagination.queryString" style="width: 200px;"
                          class="filter-item" @keyup.enter.native="handleFilter">
                </el-input>
                <el-button @click="findPage()" class="dalfBut">查询</el-button>
                <el-button @click="exportExcel()"    type="primary" class="butT">下载</el-button>
            </div>
            <el-table size="small" current-row-key="id" :data="dataList" stripe highlight-current-row>
                <el-table-column type="selection" width="55"></el-table-column>
                <el-table-column prop="fileNumber" label="档案号" align="center"></el-table-column>
                <el-table-column prop="name" label="姓名" align="center"></el-table-column>
                <el-table-column label="性别" align="center">
                    <template slot-scope="scope">
                        <span>{{ scope.row.sex == '0' ? '不限' : scope.row.sex == '1' ? '男' : '女'}}</span>
                    </template>
                </el-table-column>
                <el-table-column prop="age" label="年龄" align="center"></el-table-column>
                <el-table-column label="人群分类" align="center">
                    <template slot-scope="scope">
                        <span>
                            {{ scope.row.humanCategory == null ?  '未分类' : scope.row.humanCategory == 1 ? '脂肪肝':scope.row.humanCategory == 2 ? '高血压':scope.row.humanCategory == 3 ? '高血糖':'高血脂'}}
                        </span>
                    </template>
                </el-table-column>
                <el-table-column prop="health_manager" label="健康管理师" align="center"></el-table-column>
                <el-table-column label="操作" align="center">
                    <template slot-scope="scope">
                        <el-button type="primary" size="mini" @click="handleCreate(scope.row)">确认分类</el-button>
                        <el-button size="mini" type="danger" @click="handleDelete(scope.row)">删除</el-button>
                    </template>
                </el-table-column>
            </el-table>
            <div class="pagination-container">
                <el-pagination
                        class="pagiantion"
                        @current-change="handleCurrentChange"
                        :current-page="pagination.currentPage"
                        :page-size="pagination.pageSize"
                        layout="total, prev, pager, next, jumper"
                        :total="pagination.total">
                </el-pagination>
            </div>

            <!-- 查看评测结果标签弹层 -->
            <div class="add-form">
                <el-dialog title="查看测评报告" :visible.sync="dialogFormVisible4Edit">
                    <template>
                        <el-tabs v-model="activeName" type="card">
                            <el-tab-pane label="阳虚体质" name="first">
                                <el-form label-position="left" label-width="300px">
                                    <el-row>
                                        <el-col :span="20">
                                            <el-form-item label="1.手脚发凉吗">
                                                <el-input v-model="formData.s1"/>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="20">
                                            <el-form-item label="2.您胃部,膝部怕冷吗">
                                                <el-input v-model="formData.s2"/>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="20">
                                            <el-form-item label="3.您感到怕冷,衣服穿的比别人多吗">
                                                <el-input v-model="formData.s3"/>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="20">
                                            <el-form-item label="4.您比别人更不能受寒">
                                                <el-input v-model="formData.s4"/>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="20">
                                            <el-form-item label="5.您比别人更容易感冒">
                                                <el-input v-model="formData.s5"/>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="20">
                                            <el-form-item label="6.您吃凉的东西会不舒服">
                                                <el-input v-model="formData.s6"/>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="20">
                                            <el-form-item label="7.您吃的凉的后或拉肚子吗">
                                                <el-input v-model="formData.s7"/>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                </el-form>
                            </el-tab-pane>
                            <el-tab-pane label="心理测评" name="second">
                                <el-form label-position="left" label-width="300px">
                                    <el-row>
                                        <el-col :span="20">
                                            <el-form-item label="1.头痛">
                                                <el-input v-model="mentalityData.m1"/>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="20">
                                            <el-form-item label="2.神经过敏，心中不踏实">
                                                <el-input v-model="mentalityData.m2"/>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="20">
                                            <el-form-item label="3.头脑中有不必要的想法">
                                                <el-input v-model="mentalityData.m3"/>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="20">
                                            <el-form-item label="4.头晕和昏倒">
                                                <el-input v-model="mentalityData.m4"/>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="20">
                                            <el-form-item label="5.对异性兴趣减退">
                                                <el-input v-model="mentalityData.m5"/>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="20">
                                            <el-form-item label="6.对旁人责备求全">
                                                <el-input v-model="mentalityData.m6"/>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="20">
                                            <el-form-item label="7.感到别人能控制你的想法">
                                                <el-input v-model="mentalityData.m7"/>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="20">
                                            <el-form-item label="8.责怪别人制造麻烦">
                                                <el-input v-model="mentalityData.m8"/>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="20">
                                            <el-form-item label="9.忘记性大">
                                                <el-input v-model="mentalityData.m9"/>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="20">
                                            <el-form-item label="10.担心自己的服饰整齐及仪态端正">
                                                <el-input v-model="mentalityData.m10"/>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                </el-form>
                            </el-tab-pane>
                        </el-tabs>
                    </template>
                    <div slot="footer" class="dialog-footer">
                        <el-button @click="dialogFormVisible4Edit = false">取消</el-button>
                    </div>
                </el-dialog>
            </div>

            <!-- 新增标签弹层 -->
            <div class="add-form">
                <el-dialog title="确认分类" :visible.sync="dialogFormVisible" :before-close="handleClose">
                    <template>
                        <el-tabs v-model="activeName" type="card">
                            <el-tab-pane label="基本信息" name="first">
                                <el-form label-position="right" label-width="100px">
                                    <el-row>
                                        <el-col :span="12">
                                            <el-form-item label="档案号">
                                                <el-input v-model="formData.fileNumber"/>
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="12">
                                            <el-form-item label="姓名">
                                                <el-input v-model="formData.name"/>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="12">
                                            <el-form-item label="性别">
                                                <el-select v-model="formData.sex">
                                                    <el-option label="不限" value="0"></el-option>
                                                    <el-option label="男" value="1"></el-option>
                                                    <el-option label="女" value="2"></el-option>
                                                </el-select>
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="12">
                                            <el-form-item label="年龄">
                                                <el-input v-model="formData.age"/>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="24">
                                            <el-form-item label="疾病史">
                                                <el-input v-model="formData.medical_history" type="textarea"></el-input>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="24">
                                            <el-form-item label="遗传史">
                                                <el-input v-model="formData.family_history" type="textarea"></el-input>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="24">
                                            <el-form-item label="手术史">
                                                <el-input v-model="formData.previous_history"
                                                          type="textarea"></el-input>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                </el-form>
                            </el-tab-pane>
                            <el-tab-pane label="体检信息" name="second">
                                <div class="checkScrol">
                                    <table class="datatable">
                                        <thead>
                                        <tr>
                                            <th>档案号</th>
                                            <th>体检日期</th>
                                            <th>体检套餐</th>
                                            <th>看看体检报告</th>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        <tr v-for="c in tableData1">
                                            <td><label :for="c.id">label</label></td>
                                            <td><label :for="c.id">label</label></td>
                                            <td><label :for="c.id">label</label></td>
                                            <td><label :for="c.id">查看</label></td>
                                        </tr>
                                        </tbody>
                                    </table>
                                </div>
                            </el-tab-pane>
                            <el-tab-pane label="评估结果" name="third">
                                <div class="checkScrol">
                                    <table class="datatable">
                                        <thead>
                                        <tr>
                                            <th>档案号</th>
                                            <th>风险评估日期</th>
                                            <th>问卷状态</th>
                                            <th>看看评估报告</th>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        <tr>
                                            <td><label>{{tableData2.fileNumber}}</label>
                                            </td>
                                            <td><label>{{tableData2.assessDate}}</label>
                                            </td>
                                            <td>
                                                <label>
                                                    {{tableData2.sun_Sum >= 21 ? '阳虚':tableData2.mentality_Sum >= 21 ?
                                                    '精神障碍':'身体健康'}}
                                                </label>
                                            </td>
                                            <td>
                                                <label style="color:cornflowerblue"
                                                       @click="handleLook(tableData2.fileNumber)">查看</label>
                                            </td>
                                        </tr>
                                        </tbody>
                                    </table>
                                </div>
                            </el-tab-pane>
                            <el-tab-pane label="确认分类" name="fourth">
                                <div class="checkScrol">
                                    <table class="datatable">
                                        <el-form label-position="right" label-width="100px">
                                            <el-row>
                                                <el-col :span="12">
                                                    <el-form-item label="确认分类：">
                                                        <template>
                                                            <el-radio-group v-model="radio1" style="width: 500px">
                                                                <el-radio :label="1">脂肪肝</el-radio>
                                                                <el-radio :label="2">高血压</el-radio>
                                                                <el-radio :label="3">高血糖</el-radio>
                                                                <el-radio :label="4">高血脂</el-radio>
                                                            </el-radio-group>
                                                        </template>
                                                    </el-form-item>
                                                </el-col>
                                            </el-row>
                                            <el-row>
                                                <el-col :span="12">
                                                    <el-form-item label="健康管理师">
                                                        <template>
                                                            <el-select style="width:77%"
                                                                       v-model="formData.health_manager"
                                                                       placeholder="请选择">
                                                                <el-option
                                                                        v-for="item in options"
                                                                        :key="item.value"
                                                                        :value="item.value">
                                                                </el-option>
                                                            </el-select>
                                                        </template>
                                                    </el-form-item>
                                                </el-col>
                                            </el-row>
                                        </el-form>
                                    </table>
                                </div>
                            </el-tab-pane>
                        </el-tabs>
                    </template>
                    <div slot="footer" class="dialog-footer">
                        <el-button type="primary" @click="handleEdit()">保存</el-button>
                        <el-button @click="handleCancel()">取消</el-button>
                    </div>
                </el-dialog>
            </div>
        </div>
    </div>
</div>
</body>

<script>
    var vue = new Vue({
        el: '#app',
        data: {
            activeName: 'first',//添加/编辑窗口Tab标签名称
            pagination: {//分页相关属性
                currentPage: 1,
                pageSize: 10,
                total: 100,
                queryString: null,
            },
            dataList: [],       //分页查询展示的会员信息
            formData: {},       //用于显示单个会员的详细个人信息
            tableData1: [],      //确认分类的体检信息
            tableData2: {},      //确认分类的评估信息
            dialogFormVisible: false,//控制添加窗口显示/隐藏
            dialogFormVisible4Edit: false,//显示评测窗口
            mentalityData: {},//新增和编辑表单中检查项对应的复选框，基于双向绑定可以进行回显和数据提交
            options: [],      //健康管理师,选择框
            fileNum:'',
            obj:[],
            radio1:1
        },
        created() {
            this.findPage();
        },
        methods: {
            exportExcel() {
                window.location.href='/report/exportInterpose.do';
            },
            // 弹出查看窗口
            handleLook(row) {
                this.dialogFormVisible4Edit = true;
                this.fileNum = row;
                this.obj[0] = this.fileNum;
                //发送ajax请求，查询所有的检查项信息，转为json，赋值给tableData
                this.activeName = 'first';//默认选中first对应的tab
                axios.post("/assessment/findAll.do", this.obj).then((resp) => {
                    if (resp.data.flag) {
                        this.$message({
                                type: "success",
                                message: resp.data.message
                            },
                            this.formData = resp.data.data[0],
                            this.mentalityData = resp.data.data[1],
                            this.findPage());
                    } else {
                        this.resetForm();
                        this.$message.error(resp.data.message)
                    }
                });
            },
            //编辑
            handleEdit() {
                // alert(this.formData.radio);

                axios.post("/interpose/edit.do?humanCategory="+this.radio1,this.formData)
                    .then(resp => {
                        if (resp.data.flag) {
                            //成功
                            this.$message({
                                type:'success',
                                message:resp.data.message
                            })
                        }else{
                            this.$message({
                                type:'warning',
                                message:resp.data.message
                            })
                        }
                    }).finally(() => {
                        this.dialogFormVisible=false;
                        this.findPage();
                })

            },
            //分页查询
            findPage() {
                axios.post("/member/findByPage.do", this.pagination).then((resp) => {
                    this.pagination.total = resp.data.total;
                    this.dataList = resp.data.rows;
                })
            },
            // 重置表单
            resetForm() {
                this.activeName = 'first';      //始终显示第一栏信息--个人信息
                this.dataList = [];             //清空所有分页查询的结果
                this.formData = {};             //清空展示个人详细信息
                this.tableData1 = [];           //清空展示体检数据
                this.tableData2 = [];           //清空展示评估结果
                this.options = [];              //清空展示可选择的健康管理师
            },
            // 弹出添加窗口
            handleCreate(row) {
                // alert(row.id);
                this.resetForm();
                this.dialogFormVisible = true;
                //发送ajax请求，查询所有的检查项信息，转为json，赋值给tableData
                //根据会员的id查询详细信息
                axios.get("/member/findByMemberId.do?id=" + row.id).then(resp => {
                    this.formData = resp.data;
                    this.radio1 = +resp.data.humanCategory;
                    // alert(this.radio1);
                    this.tableData2 = resp.data.assessment;
                });
                axios.get("/user/findByRoleId.do?id=2")
                    .then(resp => {
                        this.options = resp.data.data;
                    })
            },
            //取消修改
            handleCancel() {
                this.dialogFormVisible = false;
                this.findPage();
            },
            //切换页码
            handleCurrentChange(currentPage) {
                this.pagination.currentPage = currentPage;
                this.findPage();
            },
            // 删除
            handleDelete(row) {
            },
            handleClose(done){
                done();
                this.findPage();
            }
        }
    })
</script>
</html>
